import { defineConfig } from 'vite';
import { resolve } from 'path';
import { vitePlugins } from './config/vite/plugin';
import buildSetting from './config/vite/build';

export default defineConfig(({ command, mode }) => {
	return {
		server: {
			port: 3000,
			proxy: {
				'/api': {
					// target: 'https://www.fastmock.site/mock/496937cde1239faf2f3820576016d36c/qk',
					target: 'http://192.168.30.8:8081/api',
					changeOrigin: true,
					rewrite: path => path.replace(/^\/api/, ''),
				},
			},
		},
		define: {
			__VUE_I18N_FULL_INSTALL__: true,
			__INTLIFY_PROD_DEVTOOLS__: false,
		},
		resolve: {
			alias: {
				// 还需在tscofig中配置
				'@': resolve(__dirname, 'src'),
			},
		},
		plugins: vitePlugins(command, mode),
		build: buildSetting,
	};
});
